#include <iostream>

using namespace std;

class B{
    public:
    void vf(){
        cout<<"这是B中的vf函数"<<endl;
    }
    private:
};
class D:public B{
    public:
    void vf(){
        cout<<"这是D中的vf函数"<<endl;
    }
    private:
};

int main(int argc, char const *argv[])
{
    B b,*pb;
    D d,*pd;
    pb = &b;
    pb->vf();
    pb = &d;
    pb->vf();

    //
    pd = (D*)&b;
    pd->vf();
    pd = &d;
    pd->vf();


    return 0;
}
